package com.gesee.zyspps.activity;

import com.gesee.zys.R;
import com.gesee.zyspps.ZSApplication;
import com.gesee.zyspps.utils.IntentUtil;
import com.gesee.zyspps.utils.ToastUtil;
import com.gesee.zyspps.widgets.MaterialDialog;

import android.app.ActionBar;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;

public class SettingActivity extends BaseActivity 
{
    
    private LinearLayout ll_leibie,ll_ziduan,ll_tezheng,ll_duiying;
    private MaterialDialog biaomingDialog;
    private RadioGroup biaoming_rg;
    private RadioButton jiazai_moshi,chonghui_moshi,dalei_rb,zilei_rb;
    //private TextView tv_moshi;
    private ImageView come_back;
    

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_settings);
        initView();
        initClick();
    }
    
    private void initView()
    {
        // TODO Auto-generated method stub
        come_back = (ImageView) findViewById(R.id.come_back);
        come_back.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                SettingActivity.this.finish();
            }
        });
        
//        ll_moshi = (LinearLayout) findViewById(R.id.ll_moshi);
        //ll_biaoming = (LinearLayout) findViewById(R.id.ll_biaoming);
        ll_leibie = (LinearLayout) findViewById(R.id.ll_leibie);
        ll_ziduan = (LinearLayout) findViewById(R.id.ll_ziduan);
        ll_tezheng = (LinearLayout) findViewById(R.id.ll_tezheng);
        //ll_duiying = (LinearLayout) findViewById(R.id.ll_duiying);
        
        View biaomingView = LayoutInflater.from(context).inflate(R.layout.biaoming_dialog, null);
        biaomingDialog = new MaterialDialog(this,"数据表名设置",biaomingView);
        
        biaoming_rg = (RadioGroup) biaomingView.findViewById(R.id.biaoming_rg);
        dalei_rb = (RadioButton) biaomingView.findViewById(R.id.dalei_rb);
        zilei_rb = (RadioButton) biaomingView.findViewById(R.id.zilei_rb);
        
        /*tv_biaoming = (TextView) findViewById(R.id.tv_biaoming);
        String biaomingValue = ZSApplication.getInstance().getConfig("biaoming");
        if(biaomingValue.equals("null")){
            zilei_rb.setChecked(true);
            //2表示按子类，1表示按大类
            ZSApplication.getInstance().setConfig("biaoming", "2");
            tv_biaoming.setText("数据表按管线子类命名");
            
        }
        if(biaomingValue.equals("2")){
            zilei_rb.setChecked(true);
            tv_biaoming.setText("数据表按管线子类命名");
        }
        if(biaomingValue.equals("1")){
            dalei_rb.setChecked(true);
            tv_biaoming.setText("数据表按管线大类命名");
        }*/
        /*biaoming_rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
        {
            
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId)
            {
                // TODO Auto-generated method stub
                if(checkedId == zilei_rb.getId()){
                    tv_biaoming.setText("数据表按管线子类命名");
                    ZSApplication.getInstance().setConfig("biaoming", "2");
                    ToastUtil.show(context, "重启后生效");
                    biaomingDialog.dismiss();
                }
                if(checkedId == dalei_rb.getId()){
                    tv_biaoming.setText("数据表按管线大类命名");
                    ZSApplication.getInstance().setConfig("biaoming", "1");
                    ToastUtil.show(context, "重启后生效");
                    biaomingDialog.dismiss();
                }
            }
        });*/
        
        View moshiView = LayoutInflater.from(context).inflate(R.layout.moshi_dialog, null);
        //moshiDialog = new MaterialDialog(this,"系统模式设置",moshiView);
        //moshi_rg = (RadioGroup) moshiView.findViewById(R.id.moshi_rg);
        //dakai_moshi = (RadioButton) moshiView.findViewById(R.id.dakai_moshi);
        jiazai_moshi = (RadioButton) moshiView.findViewById(R.id.jiazai_moshi);
        chonghui_moshi = (RadioButton) moshiView.findViewById(R.id.chonghui_moshi);
        
//        tv_moshi = (TextView) findViewById(R.id.tv_moshi);
        
//        String moshiValue = ZSApplication.getInstance().getConfig("moshi");
//        if(moshiValue.equals("null")){
//            chonghui_moshi.setChecked(true);
//            //3表示重绘模式，2表示加载模式，3表示打开模式
//            ZSApplication.getInstance().setConfig("moshi", "3");
//            tv_moshi.setText("重绘模式");
//            
//        }
//        if(moshiValue.equals("3")){
//            chonghui_moshi.setChecked(true);
//            //3表示重绘模式，2表示加载模式，3表示打开模式
//            tv_moshi.setText("重绘模式");
//            
//        }
//        if(moshiValue.equals("2")){
//            //3表示重绘模式，2表示加载模式，3表示打开模式
//            jiazai_moshi.setChecked(true);
//            tv_moshi.setText("加载模式");
//            
//        }
//        if(moshiValue.equals("1")){
//            //3表示重绘模式，2表示加载模式，3表示打开模式
//            dakai_moshi.setChecked(true);
//            tv_moshi.setText("打开模式");
//            
//        }
        
        
//        moshi_rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener()
//        {
//            
//            @Override
//            public void onCheckedChanged(RadioGroup group, int checkedId)
//            {
//                // TODO Auto-generated method stub
//                if(checkedId == dakai_moshi.getId()){
//                    tv_moshi.setText("打开模式");
//                    ZSApplication.getInstance().setConfig("moshi", "1");
//                    moshiDialog.dismiss();
//                }
//                if(checkedId == jiazai_moshi.getId()){
//                    tv_moshi.setText("加载模式");
//                    ZSApplication.getInstance().setConfig("moshi", "2");
//                    moshiDialog.dismiss();
//                }
//                if(checkedId == chonghui_moshi.getId()){
//                    tv_moshi.setText("重绘模式");
//                    ZSApplication.getInstance().setConfig("moshi", "3");
//                    moshiDialog.dismiss();
//                }
//            }
//        });
//        
    }


    private void initClick()
    {
        // TODO Auto-generated method stub
        
        /*ll_moshi.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                moshiDialog.show();
                moshiDialog.getButtonAccept().setText("确定");
                moshiDialog.getButtonCancel().setText("取消");
            }
        });*/
        
        /*ll_biaoming.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                biaomingDialog.show();
                biaomingDialog.getButtonAccept().setText("确定");
                biaomingDialog.getButtonCancel().setText("取消");
                
            }
        });*/
        
        ll_leibie.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                IntentUtil.startActivity(LeibieActivity.class);
            }
        });
        
        ll_ziduan.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                IntentUtil.startActivity(ZiduanActivity.class);
            }
        });
        
        ll_tezheng.setOnClickListener(new OnClickListener()
        {
            
            @Override
            public void onClick(View v)
            {
                // TODO Auto-generated method stub
                IntentUtil.startActivity(TeZhengActivity.class);
            }
        });
    }
}
